import { Component, OnInit } from '@angular/core';


@Component({
    selector: 'app-index',
    templateUrl: './index.component.html',
    styleUrls: ['./index.component.css']
})
export class IndexComponent implements OnInit {

    constructor() { }

    //组件初始化后执行
    ngOnInit() {   //从上面继承了OnInit
        // alert(1111)
        // 首页
        // 搜索显示隐藏
        $(function () {
            $("#input1").mousedown(
                function () {
                    $(".search_bomb_box").show()
                    $("#waik").hide()
                }
            )
            $(".search_bomb_box .search_top>a").mousedown(
                function () {
                    $(".search_bomb_box").hide()
                    $("#waik").show()
                }
            )
        })

        // banner轮播图
        var swiper = new Swiper('.banner_shouy', {
            pagination: {
                el: '.lunbo_banner',
                //   type: 'fraction',
            },
            autoplay: {
                delay: 2000,
                stopOnLastSlide: false,
                disableOnInteraction: false,
            },
        });

        // 快捷导航
        var swiper = new Swiper('.nav_iconbox', {
            pagination: {
                el: '.icon01',
            },
            speed: 500,
            // autoplayDisableOnInteraction: false,
        });

        // 平台公告
        let timer;
        $(document).ready(function () {
            //滚动文字
            function runtxt() {
                $(".scrollnews ul").animate({
                    marginTop: "-.4rem"
                }, 300,
                    function () {
                        $(".scrollnews ul li:last").after($(".scrollnews ul li:first"))
                        $(".scrollnews ul").css("margin-top", 0)
                    }
                )
            }
            $(".scrollnews ul li a").mouseenter(
                function () {
                    clearInterval(timer)
                }
            )
            $(".scrollnews ul li a").mouseleave(
                function () {
                    timer = setInterval(runtxt, 4000)
                }
            )
            timer = setInterval(runtxt, 4000)
        })
    }
}
